"""
C++ Template Instantiation Revealer (TIR)

A tool to reveal concrete types of C++ template instantiations at specific code locations.
"""

__version__ = "0.1.0"
__author__ = "TIR Development Team"

# Configure libclang at package level to ensure consistent configuration
_libclang_configured = False

def ensure_libclang_configured():
    """Ensure libclang is configured before importing modules that need it."""
    global _libclang_configured
    
    if _libclang_configured:
        return True
        
    try:
        from clang.cindex import Index
        # Test if it already works
        try:
            Index.create()
            _libclang_configured = True
            return True
        except:
            pass
            
        # Try to configure
        from .libclang_config import find_libclang_library
        from clang.cindex import conf
        
        lib_path = find_libclang_library()
        if lib_path:
            conf.set_library_file(lib_path)
            Index.create()  # Test
            _libclang_configured = True
            return True
    except:
        pass
    
    return False

# Try to configure libclang when package is imported
ensure_libclang_configured()

from .ast_parser import ASTParser
from .type_resolver import TypeResolver
from .formatter import OutputFormatter
from .project_context import ProjectContext
from .cli import TIRAnalyzer

__all__ = [
    "ASTParser",
    "TypeResolver", 
    "OutputFormatter",
    "ProjectContext",
    "TIRAnalyzer",
    "ensure_libclang_configured"
]